const getCity = function () {
  const url = 'http://api.map.baidu.com/geocoder/v2/'
  const ak = '填上自己申请的ak'
  wx.request({
    url,
    data: {
      ak,
      location: `${res.latitude},${res.longitude}`,
      output: 'json', //格式
    },
    success: function (res) {
      console.log(res)
      if (res.data.status == '0') {
        that.setData({
          province: res.data.result.addressComponent.province,
          city: res.data.result.addressComponent.city,
          district: res.data.result.addressComponent.district,
          isShow: true,
        })
        wx.hideLoading()
      } else {
        that.setData({
          unGeo: '未知位置',
          isShow: false,
        })
        wx.hideLoading()
      }
    },
  })
}

export default getCity
